﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    var type = $.request("type");
    var keyValue = $.request("keyValue");
    var department = $.request("department");
    var userinfo;
    $(function () {
        userinfo = getCache("DLXX");
        gridList();
    })
    function gridList() {
        var $gridList = $("#gridList");
        var queryJson = {
            keyword: $("#txt_keyword").val(),
            F_GroupId:"1"
        }
        $gridList.dataGrid({
            url: "/SystemManage/User/GetGridJson",
            postData: { queryJson: JSON.stringify(queryJson) },
            height: $(window).height() - 128,
            colModel: [
                { label: '主键', name: 'F_Id', hidden: true },
                { label: '英文名', name: 'F_Account', width: 80, align: 'left' },
                { label: '中文名', name: 'F_RealName', width: 80, align: 'left' },
                {
                    label: '性别', name: 'F_Gender', width: 60, align: 'center',
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == true) {
                            return '男';
                        } else {
                            return '女';
                        }
                    }
                },
                { label: '手机', name: 'F_MobilePhone', width: 80, align: 'left' },
                {
                    label: '部门', name: 'F_DepartmentId', width: 80, align: 'left',
                    formatter: function (cellvalue, options, rowObject) {
                        return top.clients.organize[cellvalue] == null ? "" : top.clients.organize[cellvalue].fullname;
                    }
                },
                {
                    label: '岗位', name: 'F_DutyId', width: 80, align: 'left',
                    formatter: function (cellvalue, options, rowObject) {
                        return top.clients.duty[cellvalue] == null ? "" : top.clients.duty[cellvalue].fullname;
                    }
                },
                {
                    label: "状态", name: "F_EnabledMark", width: 60, align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == 1) {
                            return '<span class=\"label label-success\">正常</span>';
                        } else if (cellvalue == 0) {
                            return '<span class=\"label label-default\">禁用</span>';
                        }
                    }
                }
                //,{ label: '备注', name: 'F_Description', width: 200, align: 'left' }
            ],
            pager: "#gridPager",
            sortname: 'F_DepartmentId asc,F_CreatorTime desc',
            viewrecords: true,
            ondblClickRow: function (rowid, iRow, iCol, e) {
                submitForm()
            }
        });
        $("#btn_search").click(function () {
            var queryJsons = {
                keyword: $("#txt_keyword").val(),
                department: userinfo.F_DepartmentId,
            }
            $gridList.jqGrid('setGridParam', {
                postData: { queryJson: JSON.stringify(queryJsons) },
            }).trigger('reloadGrid');
        });
    }
    function submitForm() {
        var selectRow = $("#gridList").jqGridRowValue();
        var fId = selectRow.F_Id;
        if (fId != "" && fId != undefined) {
            var name = selectRow.F_RealName;
            if (keyValue.length > 15)
                keyValue = "iframe" + keyValue;
            if (type == "BD") {
                top.frames[keyValue].setDBuser(String(name), String(fId));
            }
            if (type == "Mocha_ITOM") {
                top.frames[keyValue].setMocha_ITOMuser(String(name), String(fId));
            }
            $.modalClose();
        }
        else {
            $.modalAlert("请选择您要的数据！", "warning");
        }
    }
</script>

<div class="topPanel">
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="账户/姓名/手机" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
